package org.ilead.iserve.common.email;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;

/**
 * 审核通过的邮箱模板
 * @author jill
 *
 */
public class AuditEmailTemplate{
	public final static String TITLE = "亲爱的萝卜丝${userName},您已成功通过审核";
	
//	public static String CONTENT = "<br><font size=\"2\">恭喜您通过应许之地官方网站的审核。</font><br><br>" +
//			"<font size=\"3\">为方便您下载，我们提供了网盘下载的公共账号。</font><br>" +
//			"<font size=\"3\">账号：landofpromise@sina.com,密码：123456(该账号为公用请勿修改密码)。</font><br>" +
//			"<a href=\"http://${WebUrl}/login.jsp\">进入应许之地登陆页面</a><br>";
	public static String CONTENT = "恭喜您通过应许之地官方网站的审核";
	private static boolean hasInit = false;
	
	private static void init(){
		ActionContext ctx = ActionContext.getContext();
		HttpServletRequest request = (HttpServletRequest) ctx.get(ServletActionContext.HTTP_REQUEST);
		if(request != null){
			String serverName = request.getServerName();
			int serverPort = request.getServerPort();
			String contextPath = request.getContextPath();
			String webUrl = serverName + (serverPort == 80 ? "" : ":" + serverPort) + contextPath;
			CONTENT = CONTENT.replace("${WebUrl}", webUrl);
			hasInit = true;
		}
	}
	
	public static String getTitle(String userName) {
		return TITLE.replace("${userName}", userName);
	}
	
	public static String getContent() {
		if(!hasInit)
			init();
		return CONTENT;
	}

}
